/**
 * @class   wosh::entertainment::MediaTrack
 * @brief   
 *
 * used inside Palyers devices too!?
 * used inside PlayList (MediaList)
 *
 *
 ****************************************************************************
 * @version $Id: MediaTrack.h 2863 2010-08-07 04:28:58Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Entertainment_MediaTrack_H__
 #define __WOSH_Entertainment_MediaTrack_H__

 #include <woshDefs.h>
 #include <core/ResourcePath.h>
 #include <core/PropertiesProvider.h>


namespace wosh {
 template <class T> class DataFieldCollector;
 namespace entertainment {

 #define _MediaTrack_KEY_Index			"Index"
 #define _MediaTrack_KEY_Path			"Path"

 #define _MediaTrack_KEY_Length			"Length"
 #define _MediaTrack_KEY_SizeKb			"SizeKb"

 #define _MediaTrack_KEY_Artist			"Artist"
 #define _MediaTrack_KEY_Album			"Album"
 #define _MediaTrack_KEY_Title			"Title"
 #define _MediaTrack_KEY_Genre			"Genre"

 #define _MediaTrack_KEY_TrackNumber	"TrackNumber"
 #define _MediaTrack_KEY_Description	"Description"


class MediaTrack : public virtual ISerializable
 {
	WOSH_SERIALIZABLE(wosh::entertainment::MediaTrack)
	WOSH_COMPARE_RTTI(wosh::entertainment::MediaTrack)

	public:
		/**
		 * @brief   Default constructor. Init vars.
		 */
		MediaTrack();

		MediaTrack( const ResourcePath& fullpath );

		/**
		 * @brief  Copy constructor.
		 * @param m [in] the source object to be copied
		 */
		MediaTrack( const MediaTrack& m ) {
			*this = m;
		 }
		/**
		 * @brief  Empty destructor.
		 */
		virtual ~MediaTrack() { }


/** @name Setters
 * @{
 ******************************************************************************/
	public:
		void setIndex( long value ) {
			this->index = value; Properties.set( _MediaTrack_KEY_Index, value );
		 }
		void setTrack( const wosh::ResourcePath& value ) {
			this->track = value; Properties.set( _MediaTrack_KEY_Path, value.toString() );
		 }
		void setArtist( const std::string& value )	{ Properties.set( _MediaTrack_KEY_Artist, value ); }
		void setAlbum( const std::string& value )	{ Properties.set( _MediaTrack_KEY_Album, value ); }
		void setTitle( const std::string& value )	{ Properties.set( _MediaTrack_KEY_Title, value ); }
		void setGenre( const std::string& value )	{ Properties.set( _MediaTrack_KEY_Genre, value ); }
		void setLength( unsigned long seconds )		{ Properties.set( _MediaTrack_KEY_Length, Variant_TS(seconds*1000) ); }

		void clear();

//@}
/** @name Getters
 * @{
 ******************************************************************************/
	public:
		inline long getIndex() const									{ return this->index; }
	//	long getTimeStamp() const						{ return this->timestamp; }

		inline const wosh::ResourcePath& getTrack() const				{ return this->track; }
		inline wosh::ResourcePath& getTrack()							{ return this->track; }

		inline std::string getArtist() const							{ return Properties.getValueOf(_MediaTrack_KEY_Artist).toString(); }
		inline std::string getAlbum() const								{ return Properties.getValueOf(_MediaTrack_KEY_Album).toString(); }
		inline std::string getTitle() const								{ return Properties.getValueOf(_MediaTrack_KEY_Title).toString(); }
		inline std::string getGenre() const								{ return Properties.getValueOf(_MediaTrack_KEY_Genre).toString(); }

		inline const wosh::PropertiesProvider& getProperties() const	{ return this->Properties; }
		inline wosh::PropertiesProvider& getProperties()				{ return this->Properties; }

		static DataFieldCollector<MediaTrack>* getDataFields();

//@}
/** @name Operators Overloading
 * @{
 ******************************************************************************/
	public:

		virtual MediaTrack& operator=(const MediaTrack& m) {
			if (this == &m) return *this; // same object?
			this->index = m.index;
			this->track = m.track;
			this->Properties = m.Properties;
			return *this;
		 }

		virtual bool operator==(const MediaTrack &other) const {
			if ( this->track.getPath() != other.track.getPath() )
				return false;
			return true;
		 }

//@}
/** @name Serialization interface
 * @{
 ******************************************************************************/
	public:
		virtual std::string toString() const			{ return ""; }
		virtual bool updateHash( DataHashContext* hash_context ) const;
//@}
	protected:
		long index;
		wosh::ResourcePath track;
		wosh::PropertiesProvider Properties;


}; // class def

 }; // namespace entertainment
}; // namespace wosh


#endif //__WOSH_Entertainment_MediaTrack_H__
